package com.home.homepage.controller.prefecture;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.eig.common.entity.homepageentity.prefecture.TbZone;
import com.eig.common.vo.Result;
import com.home.homepage.service.prefecture.ZoneService;
import com.home.homepage.vo.prefecture.ZoneVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author ：YQ袁（2446806940@qq.com）
 * @date ：Created in 2022/12/6 21:03
 * @description：
 * @modified By：
 * @version:
 */
@RestController
@RequestMapping("/home/zone")
@Api(value = "专区管理")
public class ZoneController {
    @Autowired
    private ZoneService zoneService;


    @PostMapping("/getAllZone/{current}/{pageSize}")
    @ApiOperation(value = "分页接口")
    public Result<IPage<TbZone>> getAllZone(@PathVariable(required = true ) Integer current,
                                            @PathVariable(required = true) Integer pageSize,
                                            @RequestBody ZoneVo zoneVo
                                ){
        return zoneService.selectAll(current,pageSize,zoneVo);
    }
    @PostMapping("/changeStatus/{id}/{isDiable}")
    @ApiOperation(value = "修改状态")
    public Result changeStatus(@PathVariable String id ,@PathVariable Integer isDiable){
        System.out.println(id);
        System.out.println(isDiable);
        return zoneService.updataStat(id,isDiable);
    }

    @PostMapping("/deleteZone")
    @ApiOperation(value = "删除")
    public Result deleteZone(@RequestBody TbZone tbZone){
        return zoneService.deleteZone(tbZone.getId());
    }

    @PostMapping("/addZone")
    @ApiOperation(value = "添加和修改")
    public Result addZone(@RequestBody TbZone tbZone){
    return zoneService.addZone(tbZone);
    }
}
